// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   pk1.YCCtbl.java

package MaintMenu.VenPricingUpdTBLN;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class GENERAtbl{

    public GENERAtbl(int z)    {  //0 = partlink ; 1 = part#
        int cc=0;
        String dbInternal="";
        String dbExternal="";

        if  (z==0){
            dbInternal="partlink";
            dbExternal="PartsLink #";

        }if (z==1) {
            dbInternal="[part#]";
            dbExternal="customer part #";
        }
        int counter=1;
        int x=0;
        int y=0;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conli = DriverManager.getConnection(dbURL, "", "");
            String st[] = new String[9];

            st[0] = ("UPDATE tblmrn SET [gn#]=null");
            st[1] = ("UPDATE tblltn SET [genera#]=null");
            st[2] = ("UPDATE tblcln SET [gn#]=null");

            st[3]= ("UPDATE tblmrn AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[gn_p] = b.[Net $], " +
                    "a.[gn#] =b.Item, " +
                    "a.[gn_k] = b.StdPk " +
                    " where a.capa=yes and b.capa=yes;");

            st[4]= ("UPDATE tblltn AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[genera_p] = b.[Net $], " +
                    "a.[genera#] =b.Item, " +
                    "a.[genera_k] = b.StdPk " +
                    " where a.capa=yes and b.capa=yes;");

            st[5]= ("UPDATE tblcln AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[gn_p] = b.[Net $], " +
                    "a.[gn#] =b.Item, " +
                    "a.[gn_k] = b.StdPk" +
                    " where a.capa=yes and b.capa=yes;");

            st[6]= ("UPDATE tblmrn AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[gn_p] = b.[Net $], " +
                    "a.[gn#] =b.Item, " +
                    "a.[gn_k] = b.StdPk " +
                    " where a.capa<>yes and b.capa<>yes;");

            st[7]= ("UPDATE tblltn AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[genera_p] = b.[Net $], " +
                    "a.[genera#] =b.Item, " +
                    "a.[genera_k] = b.StdPk " +
                    " where a.capa<>yes and b.capa<>yes;");

            st[8]= ("UPDATE tblcln AS a INNER JOIN _costgenera1 AS b ON a."+dbInternal+" = b.["+dbExternal+"] " +
                    "SET " +
//                    "a.[oem_no]=b.[OEM #], " +
                    "a.[gn_p] = b.[Net $], " +
                    "a.[gn#] =b.Item, " +
                    "a.[gn_k] = b.StdPk" +
                    " where a.capa<>yes and b.capa<>yes;");

            for (x=0; x<st.length;x++){
                Statement stli = conli.createStatement();

                try {

//                    //System.out.println("Script :"+st[x]);
                    int rowsupdated = stli.executeUpdate(st[x]);
                    //System.out.print("TRU : "+rowsupdated+"\t");
                    //JOptionPane.showOptionDialog(null, "Statement : " + st[x] + "\n\nTotal record Updated : " + rowsupdated, "Update Complete", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);
                    cc++;
                    if (cc==2){
                        //System.out.println("");
                        cc=0;
                    }


                }catch(SQLException er) {
                    er.printStackTrace();
                }stli.close();
            }


            conli.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
